package com.work.service.serviceImpl;

import com.work.service.GenerateService;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

@Service
public class GenerateServiceImpl implements GenerateService {
    private static final Logger log = LoggerFactory.getLogger(GenerateServiceImpl.class);

    @Override
    public Map<String, List<String>> generateHtmlPrint(MultipartFile file) {
        try (
                InputStream inputStream = file.getInputStream()
        ) {
            Workbook workbook = new XSSFWorkbook(inputStream);
            // 遍历所有的工作簿
            for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
                Sheet sheet = workbook.getSheetAt(i);

            }
        } catch (IOException ioe) {
            log.error("读取文件失败!${}",ioe.getMessage());
            throw new RuntimeException(ioe);
        }
        return null;
    }

    @Override
    public void generateHtmlPrint(MultipartFile[] files) {

    }
}
